<?php

namespace app\api\controller;

use app\api\model\Feedback AS FeedbackModel;
use app\api\validate\Phone;

class Feedback extends Base
{
    /**
     * 添加反馈
     * @return array
     */
    public function create()
    {
        $content = input('content');
        $phone = $data['phone'] = input('phone');
        if (empty($content) || empty($phone)) {
            return self::sendResult(100, [], '反馈内容或者联系方式不能为空');
        }

        // 检测变量
        $validate = new Phone();
        if (!$validate->check($data)) {
            return self::sendResult(102, [], $validate->getError());
        }

        // 添加反馈数据
        $oauthId = $this->oauthInfo['id'];
        FeedbackModel::addOne($oauthId, $content, $phone);

        return self::sendResult(self::$okCode, [], '反馈成功');
    }
}